package com.more.offer.exercise.corejava;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

/**
 * @author pinoc
 * @date 2022/4/27
 */
public class java8Test {
	public static void main(String[] args) {
		List<Integer> ints = (List<Integer>) Arrays.asList(1,2,4,6,9);
		List<Integer> collect = ints.stream().map(n -> n*n).collect(toList());


		List<Integer> integers = Arrays.asList(1, 2, 3);
		List<Integer> integers1 = Arrays.asList(3, 4);
		List<int[]> collect1 = integers.stream().flatMap(i -> integers1.stream().map(j -> new int[]{i, j})
		).collect(toList());

		collect1.forEach(s -> {
			System.out.println(s[0]+" " + s[1]);
		});

		ints.forEach(System.out::print);
		System.out.println();
		ints.parallelStream().forEach(System.out::print);
		System.out.println();
	}
}
